<template>
  <CommonCard title="今日销售额" :value="numberFormat(salesToday)">
    <template #default>
      <div class="compare">
        <div class="emphasis">日同比 &nbsp;{{salesGrowthLastDay}}% &nbsp;<span class="decrement"></span></div>
        <div class="emphasis">月同比 &nbsp;{{salesGrowthLastMonth}}% &nbsp;<span class="increment"></span></div>
      </div>
    </template>

    <template #footer>
      <div>昨日销售额 <span class="emphasis">{{moneyFormat(salesLastDay)}}</span></div>
    </template>
  </CommonCard>
</template>

<script lang="ts">
import CommonCard from './CommonCard.vue';
export default {
  name: 'TodaySales',
  components: {
    CommonCard
  }
};
</script>
<script lang="ts" setup>
import { onMounted, computed } from 'vue';
import { useReportDataStore } from '@/stores/reportData';
import useFormat from '@/hooks/useFormat';
// 获取store对象
const reportDataStore = useReportDataStore();

// js中的函数，只要调用就会有返回值
// const obj = useFormat()
const { numberFormat, moneyFormat } = useFormat();

// 1. 今日销售额
const salesToday = computed(() => reportDataStore.reportData.salesToday);
// 2. 日同比
const salesGrowthLastDay = computed(() => reportDataStore.reportData.salesGrowthLastDay);
// 3. 月同比
const salesGrowthLastMonth = computed(() => reportDataStore.reportData.salesGrowthLastMonth);
// 4. 昨日销售额
const salesLastDay = computed(() => reportDataStore.reportData.salesLastDay);
</script>


<style lang="scss" scoped>
.compare {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  > div {
    display: flex;
    align-items: center;
  }
}
</style>